package com.huahua.api.controller.crypto;

import com.huahua.api.entity.base.R;
import com.huahua.api.entity.param.UnicodeParam;
import com.huahua.api.service.UnicodeService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

/**
 * Unicode编码转换控制器
 */
@RestController
@RequestMapping("/crypto/unicode")
@RequiredArgsConstructor
public class UnicodeController {

    private final UnicodeService unicodeService;

    /**
     * Unicode编码转换
     *
     * @param param 转换参数
     * @return 转换结果
     */
    @PostMapping("/convert")
    public Mono<R<String>> convert(@RequestBody UnicodeParam param) {
        return unicodeService.convert(param)
                .map(R::success);
    }
}
